package com.deuwise.system.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.deuwise.common.validator.group.AddGroup;
import com.deuwise.common.validator.group.UpdateGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;

/**
 * 
 *@author deuwise
 *@date 2018-11-06 14:15:04
 */
@Data
@EqualsAndHashCode(callSuper=true)
@TableName("sys_menu")
public class SysMenu extends Model<SysMenu>  implements Serializable {
    /**唯一主键*/
    @ApiModelProperty("唯一主键")
    @JSONField(ordinal = 1)
    @TableField("id")
    @TableId
    private String id;

    /**父节点Id 默认0*/
    @ApiModelProperty("父节点Id 默认0")
    @TableField("parent_id")
    @JSONField(ordinal = 2)
    private String parentId;

    /**菜单名称*/
    @ApiModelProperty("菜单名称")
    @TableField("name")
    @JSONField(ordinal = 3)
    @NotBlank(message ="菜单名称不能为空",groups = {AddGroup.class, UpdateGroup.class})
    @Length(max =60,message ="菜单名称长度不能超过{max}",groups ={AddGroup.class, UpdateGroup.class})
    private String name;

    /**菜单URL*/
    @ApiModelProperty("菜单URL")
    @TableField("url")
    @JSONField(ordinal = 4)
    @Length(max =120,message ="菜单URL长度不能超过{max}",groups ={AddGroup.class, UpdateGroup.class})
    private String url;

    /**
     * 父菜单名称
     */
    @ApiModelProperty("父菜单名称")
    @TableField(exist=false)
    @JSONField(ordinal = 5)
    private String parentName;

    /**授权(多个用逗号分隔，如：user:list,user:create)*/
    @ApiModelProperty("授权(多个用逗号分隔，如：user:list,user:create)")
    @TableField("perms")
    @JSONField(ordinal = 6)
    private String perms;

    /**类型   0：目录   1：菜单   2：按钮*/
    @ApiModelProperty("类型   0：目录   1：菜单   2：按钮")
    @TableField("type")
    @JSONField(ordinal = 7)
    private Integer type;

    /**菜单图标*/
    @ApiModelProperty("菜单图标")
    @TableField("icon")
    @JSONField(ordinal = 8)
    private String icon;

    /**排序*/
    @ApiModelProperty("排序")
    @TableField("order_num")
    @JSONField(ordinal = 9)
    private Integer orderNum;

    /**创建时间*/
    @ApiModelProperty("创建时间")
    @TableField("create_time")
    @JSONField(ordinal = 10)
    private Date createTime;

    /**更新时间*/
    @ApiModelProperty("更新时间")
    @TableField("update_time")
    @JSONField(ordinal = 11)
    private Date updateTime;

    /**应用ID*/
    @ApiModelProperty("应用ID")
    @TableField("app_id")
    @JSONField(ordinal = 12)
    private String appId;

    /**
     * ztree属性
     */
    @TableField(exist=false)
    @JSONField(ordinal = 13)
    private Boolean open;

    @TableField(exist=false)
    @JSONField(ordinal = 14)
    private List<SysMenu> list;

   @Override
    protected Serializable pkVal() {
        return id;
    }
}